import { BrowserModule } from '@angular/platform-browser';
import { HttpModule,Http, XHRBackend, RequestOptions } from '@angular/http';
import { NgModule, ErrorHandler } from '@angular/core';

import { IonicApp, IonicModule, IonicErrorHandler,LoadingController } from 'ionic-angular';
import { InAppBrowser } from '@ionic-native/in-app-browser';
import { SplashScreen } from '@ionic-native/splash-screen';
import { IonicStorageModule } from '@ionic/storage';
import { YIonicApp } from './app.component';


import { ConferenceData } from '../providers/conference-data';
import { UserData } from '../providers/user-data';
import { AppService } from '../providers/app-service';
import { OauthService } from '../providers/oauth-service';
import {HttpInterceptor} from "../commons/httpInterceptor";
import {PubSubService} from "../commons/pubSubService";

@NgModule({
  declarations: [
    YIonicApp
  ],
  imports: [
    BrowserModule,
    HttpModule,
    IonicModule.forRoot(YIonicApp),
    IonicStorageModule.forRoot()
  ],
  bootstrap: [IonicApp],
  providers: [
    { provide: ErrorHandler, useClass: IonicErrorHandler },
    ConferenceData,
    UserData,
    OauthService,
    AppService,
    InAppBrowser,
    SplashScreen,
    PubSubService,
    {
        provide: Http,
        useFactory: ( 
                      backend: XHRBackend,
                      defaultOptions: RequestOptions,
                      pubsub: PubSubService,loading:LoadingController,userData: UserData) => new HttpInterceptor(backend, defaultOptions, pubsub,loading,userData),
        deps: [XHRBackend, RequestOptions, PubSubService,LoadingController,UserData]
    }
  ]
})
export class AppModule { }
